<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>{$user.truename}个人中心</title>
    <script type="text/javascript">var root = "__APP__";</script>
     <link rel="stylesheet" type="text/css" href="__PUBLIC__/style/Course/common.css">
       <link rel="stylesheet" type="text/css" href="__PUBLIC__/style/Plug/Validation-Engine/validationEngine.jquery.css">
    <link rel="stylesheet" href="__PUBLIC__/script/Plug/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="__PUBLIC__/script/Plug/bootstrap/css/bootstrap-theme.min.css">
    <script src="__PUBLIC__/script/Common/jquery-1.10.2.js"></script>
    <script src="__PUBLIC__/script/Plug/bootstrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/script/Plug/Validation-Engine/jquery.validationEngine.js"></script>
    <script type="text/javascript" src="__PUBLIC__/script/Plug/Validation-Engine/jquery.validationEngine-zh_CN.js"></script>
    <script type="text/javascript" src="__PUBLIC__/script/Plug/laydate/laydate.dev.js"></script>

</head>
<body> 
  <include file="Course:t_head" active="homeowork-li"/>
    <div class="main">
    
      <div class="pub-area">
           <a href="javascript:;" class="btn btn-success sub-button" id="pubHomework">发布作业</a>
      </div>


  <table class="table table-hover tableList table-striped table-bordered">
    <tr>
        <th>ID</th>
        <th>作业名称</th>
        <th>作业要求</th>
        <th>截止时间</th>
        <th>操作</th>
    </tr>
    <volist name="homeworkList" id="co">
        <tr>
            <td>{$co.id}</td>
            <td>{$co.homework_name}</td>
            <td><a href="__MODULE__/Course/s_ShowHomeworkInfo/homeworkId/{$co.id}/courseId/{$Think.get.courseId} ">查看</a></td> 
            <td>{$co.homework_expires|date="Y-m-d",###}</td>
            <td>
            <a href="javascript:;" class="btn btn-success btn-sm">编辑</a>
            <a href="__CONTROLLER__/t_HomeworkManage/courseId/{$Think.get.courseId}/homewokrId/{$co.id}" class="btn btn-success btn-sm">管理</a>
            </td>  
        </tr>
    </volist>
  </table>

</div>
    <div class="modal fade bs-example-modal-sm submitModal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
      <div class="modal-dialog modal-sm">
        <div class="modal-content" style="width:350px;height:320px;">

       <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
            <h4 class="modal-title">发布作业</h4>

       </div>
          <form id="homework_add">
            <div class="input-group">
              <span class="input-group-addon" id="basic-addon1">作业名称</span>
              <input type="text" name="homework_name" id="homework_name" class="validate[required,maxSize[12]] form-control"> 
            </div>
            <div class="input-group">
              <span class="input-group-addon" id="basic-addon1">作业要求</span>
              <textarea class="form-control" name="homework_about" id="homework_about" rows="3" class="validate[required,maxSize[200] form-control"></textarea>
            </div>
            <div class="input-group">
              <span class="input-group-addon" id="basic-addon1">截止时间</span>
              <input type="text" name="homework_expires" id="homework_expires" class="validate[required] form-control">  
            </div>
            <input type="submit" value="新增作业" class="btn btn-success btn-home">
            <input type="hidden" value="{$Think.get.courseId}" name="course_id">
          </form>
      </div>
    </div>
    </div>
    <div class="modal fade bs-example-modal-sm" id="message" tabindex="-1" role="dialog"  aria-hidden="true">
    <div class="modal-dialog modal-sm">
      <div class="modal-content">

        <div class="modal-header">
          <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
          <h4 class="modal-title" id="mySmallModalLabel">提示</h4>
        </div>
        <div class="modal-body" style="  text-align: center;line-height: 60px;height: 100px;">
          
        </div>
      </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
  </div><!-- /.modal -->
  <script type="text/javascript">
        
           $('#pubHomework').click(function(){
                $('.submitModal').modal(true);
                // 
           });
           $(function(){
/*  $(document).on('click','#modify_pwd',function(){
        var $pwd   = $("input[name=pwd]")[0];
        var $rqpwd = $("input[name=rqpwd]")[0];
    });*/ 
        laydate({
            elem: '#homework_expires'
        });

        $('#homework_add').validationEngine({
            'custom_error_messages':{
                '#homework_name' : {
                    'required':{
                        'message' : '* 请输入作业名称'
                    }
                },
                '#homework_about': {
                    'required' : {
                        'message': '* 请输入作业要求'
                    }
                },
                 '#homework_expires': {
                    'required' : {
                        'message': '* 请选择截止时间'
                    }
                }
            },
            'onValidationComplete' : function(form,status){
                if (status === true) {
                    var $data = $('#homework_add').serialize();
                  
                   $.post('/vshow/index.php/Home/Course/addHomework',$data,function(data,status){
                    $('.submitModal').modal('hide');
                    if (data.status == 0 ) {
                          $('#message .modal-body').text(data.message);
                          $('#message').modal(true);
                      }else{
                           $('#message .modal-body').text(data.message);
                           $('#message').modal(true);
                             setTimeout(function(){
                          $('#message').modal('hide');
                          location.reload(true);
                       },1500)
                       }
                   })
                }
            },
            // 'ajaxFormValidation' : true,
            'ajaxFormValidationMethod' : 'post'
    }); 
});


    </script>
    <!-- <include file="Public:footer" /> -->
</body>
</html>